The Scripting app supports advanced search interactions similar to SwiftUI. You can add a search bar, control its visibility and placement, react to changes in input, and display dynamic suggestions.
searchableMarks a view as searchable by displaying a search field and binding it to a state value.
<List>).value is the current search query, which you control via state.onChanged callback updates the state when the user types.prompt as placeholder text.placement to customize where the search field appears.presented to programmatically show or dismiss the search field.SearchFieldPlacement options| Value | Description |
|---|---|
'automatic' |
Default behavior, automatically selected placement. |
'navigationBarDrawer' |
Appears as a drawer below the navigation bar. |
'navigationBarDrawerAlwaysDisplay' |
Always shows the drawer, even when inactive. |
'navigationBarDrawerAutomaticDisplay' |
Shows drawer only when needed. |
'toolbar' |
Displays the search field in the toolbar. |
'sidebar' |
Places the search field in the sidebar (iPad/macOS-style). |
searchSuggestionsDisplays a list of suggestions below the search field as the user types.
Use this to return a list of suggestions, typically based on the user's input.
searchSuggestionsVisibilityControls when and where search suggestions are shown.
SearchSuggestionsPlacementSet options| Value | Description |
|---|---|
'content' |
Shows suggestions inline with the content. |
'menu' |
Shows suggestions in a popover or dropdown. |
'all' |
Applies to all available placements. |
searchCompletionAssociates a tappable search suggestion with a complete search query string.
Apply this modifier to suggestion views (such as <Text>) to indicate what value should be filled into the search field when the user taps the suggestion.
When tapped, this will set the search field to "Mango".
| Modifier | Purpose |
|---|---|
searchable |
Adds a search field with bindings and customization. |
searchSuggestions |
Provides a list of custom suggestions. |
searchSuggestionsVisibility |
Controls where and when suggestions are shown. |
searchCompletion |
Defines the value used when a suggestion is selected. |
These modifiers work together to create a responsive, interactive search experience in any scrollable view like <List>.